package class3;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class demo3 {
    public static void main(String[] args) {
        FileInputStream in=null;
        FileOutputStream out=null;
        try {
            in=new FileInputStream("D:\\temp\\ok.txt");
            out=new FileOutputStream("D:\\temp\\test\\ok1.txt");
            int len=0;
//            while ((len=in.read())!=-1){
//            out.write(len);
//            }

            while(len!=-1){
                out.write(len);
                len= in.read();

            }

        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
                try {
                    if (out!=null){
                        out.close();
                    }
                    if (in!=null){
                        in.close();
                    }
                    System.out.println("复制成功");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
        }
    }
}
